Add support to retrieve repository statistics for a project via REST Statistics for a repository can now be retrieved by GET on '/projects/*/statistics.git'. To get the statistics for a repository the global capability 'Run Garbage Collection' is required. Normal users should not be interested in the repository statistics which is why we keep the access restricted for now. Change-Id: If5a2def2f840e1b30206a19a923d02e813db4049 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt index 909f3a4..c463d4e 100644 --- a/Documentation/rest-api-projects.txt +++ b/Documentation/rest-api-projects.txt
@@ -374,6 +374,40 @@ "refs/heads/stable" ---- +[[get-repository-statistics]] +Get Repository Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~ +[verse] +'GET /projects/link:#project-name[\{project-name\}]/statistics.git' + +Return statistics for the repository of a project. + +.Request +---- + GET /projects/plugins%2Freplication/statistics.git HTTP/1.0 +---- + +The repository statistics are returned as a +link:#repository-statistics-info[RepositoryStatisticsInfo] entity. + +.Response +---- + HTTP/1.1 200 OK + Content-Disposition: attachment + Content-Type: application/json;charset=UTF-8 + + )]}' + { + "number_of_loose_objects": 127, + "number_of_loose_refs": 15, + "number_of_pack_files": 15, + "number_of_packed_objects": 67, + "number_of_packed_refs": 0, + "size_of_loose_objects": 29466, + "size_of_packed_objects": 9646 + } +---- + [[dashboard-endpoints]] Dashboard Endpoints ------------------- @@ -805,6 +839,24 @@ in the `project.config` file to the `refs/meta/config` branch. |============================= +[[repository-statistics-info]] +RepositoryStatisticsInfo +~~~~~~~~~~~~~~~~~~~~~~~~ +The `RepositoryStatisticsInfo` entity contains information about +statistics of a Git repository. + +[options="header",width="50%",cols="1,6"] +|====================================== +|Field Name |Description +|`number_of_loose_objects` |Number of loose objects. +|`number_of_loose_refs` |Number of loose refs. +|`number_of_pack_files` |Number of pack files. +|`number_of_packed_objects`|Number of packed objects. +|`number_of_packed_refs` |Number of packed refs. +|`size_of_loose_objects` |Size of loose objects in bytes. +|`size_of_packed_objects` |Size of packed objects in bytes. +|====================================== + GERRIT ------